document.addEventListener('DOMContentLoaded', function() {
    const sidebar = document.querySelector('.sidebar');
    sidebar.addEventListener('click', function(e) {
        if (e.target.tagName === 'A' && e.target.classList.contains('list-group-item')) {
            e.preventDefault();
            const targetId = e.target.dataset.target;
            // 隐藏所有内容区域
            const contentAreas = document.querySelectorAll('[id^="content-"]');
            contentAreas.forEach(area => {
                area.style.display = 'none';
            });
            // 显示目标内容区域
            const targetArea = document.getElementById(targetId);
            if (targetArea) {
                targetArea.style.display = 'block';
            }
            // 更新侧边栏active状态
            sidebar.querySelectorAll('.list-group-item').forEach(link => {
                link.classList.remove('active');
            });
            e.target.classList.add('active');
        }
    });
    // 初始化显示当前active对应的内容
    const initialActive = sidebar.querySelector('.list-group-item.active');
    if (initialActive) {
        const initialTarget = initialActive.dataset.target;
        const initialArea = document.getElementById(initialTarget);
        if (initialArea) {
            initialArea.style.display = 'block';
        }
    }
});